//
//  PhotoManageCollectionViewCell.m
//  KuWoCan
//
//  Created by 周小宏 on 2017/4/19.
//  Copyright © 2017年 hwd. All rights reserved.
//

#import "PhotoManageCollectionViewCell.h"

@interface PhotoManageCollectionViewCell ()

@property (nonatomic, strong) UIImageView *imageV;
@end

@implementation PhotoManageCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor whiteColor];

        self.backgroundImageV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"camera"]];
        self.backgroundImageV.contentMode = UIViewContentModeCenter;
        self.backgroundImageV.backgroundColor = [UIColor colorWithRed:0.90 green:0.91 blue:0.91 alpha:1.00];
        [self.contentView addSubview:self.backgroundImageV];
        [self.backgroundImageV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self.contentView);
        }];
        
        self.imageV = [[UIImageView alloc] initWithFrame:CGRectZero];
        self.imageV.backgroundColor = [UIColor clearColor];
        [self.contentView addSubview:self.imageV];
        [self.imageV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self.contentView);
        }];
    }
    return self;
}

- (void)setImageWithPicListModel:(nullable PicListModel *)model {
    if (model.imgs) {
        [self.imageV sd_setImageWithURL:[NSURL URLWithString:model.imgs]];
        self.backgroundImageV.hidden = YES;
    } else {
        self.imageV.image = [UIImage new];
        self.backgroundImageV.hidden = NO;
    }
}

@end
